package com.fs.system.college_admin.controller;

import com.fs.system.college_admin.domain.Grade;
import com.fs.system.college_admin.domain.Speciality;
import com.fs.system.college_admin.service.CollegeAdminSpecialityService;
import com.fs.system.common.ResponseData;
import com.fs.system.teacher.domain.Teacher;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/collegeAdminSpeciality")
public class CollegeAdminSpecialityController {
    @Autowired
    private CollegeAdminSpecialityService collegeAdminSpecialityService;

    /*@RequestMapping("/getSpeciality")
    public ResponseData getSpeciality(){
        return collegeAdminSpecialityService.getSpeciality();
    }*/

    /**
     * 查询专业列表
     * 根据collegeId查询
     */
    @GetMapping("/selectSpeciality")
    public ResponseData selectSpeciality(Speciality speciality,
                                         @RequestParam(defaultValue = "1")Integer page,
                                         @RequestParam(defaultValue = "5")Integer size){
        System.out.println(speciality+"00000000000000");
        PageInfo<Speciality> list = collegeAdminSpecialityService.selectSpeciality(speciality,page,size);
        return new ResponseData("200","查询成功",list);
    }

    /**
     * 查询所有专业列表
     */
    @GetMapping("/getAllSpeciality")
    public ResponseData getAllSpeciality(Speciality speciality){
        List<Speciality> list = collegeAdminSpecialityService.getAllSpeciality(speciality);
        return new ResponseData("200","查询成功",list);
    }

    /**
     * 新增专业
     */
    @PostMapping("/addSpeciality")
    public ResponseData addSpeciality(@RequestBody Speciality speciality){
        collegeAdminSpecialityService.addSpeciality(speciality);
        return new ResponseData("200","新增成功");
    }

    /**
     * 删除方法
     */
    @PutMapping("/deleteSpeciality")
    public ResponseData deleteSpeciality(@RequestParam Long specialityId, @RequestParam String updateBy){
        collegeAdminSpecialityService.deleteSpeciality(specialityId,updateBy);
        return new ResponseData("200","删除成功");
    }

    /**
     * 修改专业信息
     */
    @PutMapping("/updateSpeciality")
    public ResponseData updateSpeciality(@RequestBody Speciality speciality){
        collegeAdminSpecialityService.updateSpeciality(speciality);
        return new ResponseData("200","修改成功");
    }

}
